<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>dom节点的动态和静态特征</title>
</head>
<body>
    <h2></h2>
    <h2></h2>
    <button onclick="add()">insert</button>
    <script>
        // 以getElement开头获取的具有动态特征
        const dth2 = document.getElementsByTagName('h2');
        // 如果想要动态特征获取的具有静态特征
        const clone = Array.prototype.slice.call(dth2);
        const jth2 = document.querySelectorAll('h2');
        console.log(dth2.length);
        console.log(clone.length);
        console.log(jth2.length);
        function add(){
            document.body.insertAdjacentHTML('beforeend','<h2>houdunren.com</h2>');
            console.log(dth2.length);
            console.log(clone.length);
            console.log(jth2.length);
        }
    </script>
</body>
</html>